<template>
  <g>
    <text :x="x" :y="y-12" fill="red">{{text}}</text>
    <rect :x="x" :y="y" rx="10" ry="10" width="200" height="80"/>
    <path :d="computedLink()" :style="style" class="defaultArrow"></path>

  </g>
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'

@Component
export default class extends Vue {
  @Prop() x!: number;
  @Prop() y!: number;
  @Prop() text!: string;
  textInfo: any = {
    cross_sorting_info: '投线任务',
    pick_info: '储位拣货任务',
    route_check_info: '投线任务',
    shortage_info: '缺货',
    check_info: '复核任务',
    policy_info: '总拣再投线',
    variance_info: '差异中心'
  };
  style: string = '';

  computedLink () {
    let fX = this.x + 100; let fY = this.y + 80; let tX = 500; let tY = 330
    return `M ${fX} ${fY}  Q ${fX} ${fY + 50} ${(tX + fX) / 2} ${(tY + fY) / 2} T ${tX} ${tY}`
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
   .sprite {
    width: 300px;
    height: 100px;
    overflow: hidden;
    border-radius: 8px;
    box-sizing: border-box;

    .sprite-child {
      width: 300px;
      height: 50px;
      background-color: lightgray;
      box-sizing: border-box;
    }
    .sprite-child:first-child {
      border-bottom: 1px solid gray;
    }

    .active {
      background-color: lightskyblue;
    }

    .svg {
      position: absolute;

    }
  }
  .defaultArrow {
    stroke: #00c0ff;
    stroke-width: 3px;
    fill: none;
    stroke-dasharray: 5px;
    stroke-dashoffset: 1000px;
    animation: grown 40s infinite linear;
  }

  @keyframes grown {
  to{
    stroke-dashoffset: 0px;
  }
}
</style>
